home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
demodisks
/
drives
/
1581-demo.lzh
/
burst subs.lst
< prev
next >
Wrap
File List
|
1994-10-19
|
59KB
|
989 lines
.main. hcd65xx v3.1 03-23-87 page 1
0:burst subs.src,s,r
error addr code seq source statement
1 ;************************************************************************
2 ;* *
3 ;* ------------------ *
4 ;* ---------------------- BURST SUBROUTINES ---------------------- *
5 ;* ------------------ *
6 ;* *
7 ;* These assembly language routines are provided for your convenience. *
8 ;* For most users, the BURST commands are very cryptic, requiring you *
9 ;* to write your own assembly language programs to make use of them. *
10 ;* The set of assembly language subroutines provided in this listing *
11 ;* are designed to allow anyone to make use of the BURST routines very *
12 ;* easily. A BASIC program needs simply to POKE the appropriate values *
13 ;* into the variable locations shown below, and then SYS to the desired *
14 ;* routine. All of the BURST protocol and handshaking is done for you. *
15 ;* The BASIC program can then PEEK any values returned. *
16 ;* *
17 ;* The routines in this listing that require data buffer storage areas *
18 ;* are passed the location of the buffer in BUFLOC. BUFLOC points to *
19 ;* RAM location in RAM bank 0 of the start of the buffer. Since the *
20 ;* KERNEL and I/O are needed, RAM exists only up to $C000. So, you are *
21 ;* free to use any RAM past your BASIC text program, up to $C000 (BASIC *
22 ;* text normally starts at $1C00. If bit-map graphics are enabled, *
23 ;* then BASIC text starts at $4000). If you want to PEEK and POKE this *
24 ;* memory from BASIC, be sure to execute the 'BANK 0' command. This *
25 ;* tells BASIC to PEEK and POKE to the RAM under the BASIC ROMs. *
26 ;* If you want to make your program real intelligient, there are *
27 ;* pointers to the beginning and end of BASIC text ($002D and $1210, *
28 ;* respectively). As a general rule, work your way back from $C000, *
29 ;* and you'll be OK. *
30 ;* *
31 ;* To use these routines, your BASIC program must BLOAD the file *
32 ;* 'BURST SUBS.BIN' before they can be used. They load at $1300, so *
33 ;* they are in a safe place below BASIC text area. *
34 ;* *
35 ;* There is no BURST FORMAT routine provided. BURST formats can be *
36 ;* accomplished easily from BASIC. For example, the following BASIC *
37 ;* commands will format physical tracks 10 through 20 of the disk with *
38 ;* 5 1024 byte sectors: *
39 ;* *
40 ;* OPEN 1,8,15 *
41 ;* PRINT#1,"U0";CHR$(3);CHR$(20);CHR$(5);CHR$(10); *
42 ;* *
43 ;* Note the use of the semicolon (;) at the end of the statement. This *
44 ;* is very important! If there was no semicolon, the C128 would *
45 ;* send a carriage return after the last parameter. Since the 1581 *
46 ;* counts the number of bytes sent to determine the number of optional *
47 ;* parameters that are being sent, it would misinterpret the carriage *
48 ;* return as the next optional parameter. In this case, it would be *
49 ;* fill byte. Any formatting errors can be checked via the command *
50 ;* channel. *
51 ;* *
52 ;* Since the BURST commands make use of the command channel to the *
53 ;* drive, the command channel must first be OPENed in your BASIC *
54 ;* program. The logical file number which you assigned to the command *
55 ;* channel should be poked to LF before calling any of these routines. *
56 ;* *
57 ;************************************************************************
.main. hcd65xx v3.1 03-23-87 page 2
0:burst subs.src,s,r
error addr code seq source statement
58
59
60
61 ;************************************************************************
62 ; Variables - Values from BASIC can be POKEd, PEEKed to these areas.
63 ;************************************************************************
=1300 64 *=$1300
65
1300 00 66 STATUS .byte 0 ; status byte
1301 08 67 DEV .byte 8 ; device number
1302 08 68 LF .byte 8 ; logical file number
1303 =1304 69 TRACK *=*+1 ; track
1304 =1305 70 SECTOR *=*+1 ; sector
1305 =1306 71 NUMSEC *=*+1 ; Number of sectors.
1306 =1308 72 BUFLOC *=*+2 ; Page # of buffer to get/put data.
1308 =1309 73 SECSIZE *=*+1 ; Sector size (1=256, 2=512, 4=1024)
1309 =130a 74 SIDE *=*+1 ; Physical side of the disk (0 or 1).
130a =130b 75 MINSEC *=*+1 ; Minimum logical sector found in QUERY.
130b =130c 76 MAXSEC *=*+1 ; Maximum logical sector found in QUERY.
130c =130d 77 INTLV *=*+1 ; Physical interleave found in QUERY.
130d =130e 78 FLAG *=*+1 ; Empty track flag.
79 ; This flag is used to indicate that the
80 ; track or data just read contains all 0's.
81 ; This is handy in some cases, such as
82 ; during a disk copy program. When a disk
83 ; is formatted, the sectors are filled with
84 ; 0's. If a sector to be copied contains
85 ; all 0's, then we don't bother to
86 ; write it to the destination disk (which
87 ; can end up saving a great deal of time!).
88
89 ;*************************************************************************
90 ; Other variables used in the following routines....
91 ;*************************************************************************
92
130e 93 cmdline
130e 55 30 94 .byte 'u0' ; Burst prefix.
=131a 95 *=*+10 ; Parameter space for burst command.
131a =131b 96 cmdlen *=*+1 ; Length of the command string (# of bytes).
131b =131c 97 oldclk *=*+1 ; Status of clock line.
131c =131d 98 temp *=*+1
99
=1335 100 *=$1335
1335 47 52 45 101 .byte 'greg berlin' ; Written by Greg Berlin, 3/87
1338 47 20 42
133b 45 52 4c
133e 49 4e
102
103 ;**************************************************************************
104 ; JUMP TABLE of available burst routines. SYS to these locations from
105 ; BASIC. The BURST routines themselves can then be modified or customized
106 ; without affecting the SYS locations from BASIC.
107 ;**************************************************************************
=1340 108 *=$1340
109
1340 110 J_INQUIRE_FORMAT
1340 4c 148d 111 jmp INQUIRE_FORMAT
.main. hcd65xx v3.1 03-23-87 page 3
0:burst subs.src,s,r
error addr code seq source statement
1343 112 J_PHYSICAL_READ
1343 4c 136b 113 jmp PREAD
1346 114 J_LOGICAL_READ
1346 4c 135e 115 jmp LREAD
1349 116 J_PHYSICAL_WRITE
1349 4c 13f9 117 jmp PWRITE
134c 118 J_LOGICAL_WRITE
134c 4c 13ec 119 jmp LWRITE
134f 120 J_MEMORY_READ
134f 4c 1532 121 jmp MEMORY_READ
1352 122 J_MEMORY_WRITE
1352 4c 1594 123 jmp MEMORY_WRITE
1355 124 J_DUMP_CACHE
1355 4c 15fb 125 jmp DUMP_CACHE
1358 126 J_QUERY_FORMAT
1358 4c 14af 127 jmp QUERY_FORMAT
135b 128 J_COMPARE_MEMORY
135b 4c 162a 129 jmp COMPARE_MEMORY
130
131 ;**************************************************************************
132 ; Locations of important C128 stuff...
133 ;**************************************************************************
134
=ffc9 135 chkout=$ffc9 ; kernel channel output
=ffcc 136 clrchn=$ffcc ; kernel clear channel
=ffba 137 setlfs=$ffba ; kernel set logical file number
=ffbd 138 setnam=$ffbd ; kernel set filename
=ffd2 139 bsout =$ffd2 ; kernel basic input/output
=ff47 140 spin_out=$ff47 ; Set up fast serial for input or output.
141 ; SEC for output, CLC for input.
=dd00 142 d2pra =$dd00 ; C128 serial port location
=0010 143 clkout=$10 ; slow serial clock output bit mask
=0040 144 clkin =$40 ; slow serial clock input bit mask
=dc0d 145 d1icr =$dc0d ; 6526 CIA interrupt control register
=dc0c 146 d1sdr =$dc0c ; 6526 CIA serial data register
=00fa 147 buffer=$fa ; zero page pointer variable
=00fc 148 buffer2=$fc ; zero page pointer variable
149
150 ;**************************************************************************
151 ; BURST command primitives
152 ;**************************************************************************
153
=0000 154 PBURSTRD =$00 ; Physical burst read.
=0002 155 PBURSTWR =$02 ; Physical burst write.
=0080 156 LBURSTRD =$80 ; Logical burst read
=0082 157 LBURSTWR =$82 ; Logical burst write.
=0004 158 BURST_INQUIRE =$04 ; Burst inquire.
=009c 159 DUMPCACHE =$9C ; Dump track cache ('force' bit set)
=0086 160 BURST_QUERY =$86 ; Query disk format.
161
162 ;**************************************************************************
163 ;* ------------------------- BURST ROUTINES ---------------------------- *
164 ;**************************************************************************
165
135e 166 LREAD ;Logical sector read from the device indicated by LF.
167 ;The track and sector are in TRACK, SECTOR. The location
168 ;of start of the C128 buffer to put the read data in BUFLOC.
.main. hcd65xx v3.1 03-23-87 page 4
0:burst subs.src,s,r
error addr code seq source statement
169 ;Status byte from drive is returned in STATUS.
170
135e a9 80 171 lda #lburstrd ;logical burst read command
1360 8d 1310 172 sta cmdline+2
1363 a9 01 173 lda #$01
1365 8d 1308 174 sta SECSIZE ;Logical sector size is always 256 bytes.
1368 4c 1377 175 jmp READ
176
136b 177 PREAD ;Physical sector read from device indicated by LF.
178 ;The track and sector are in TRACK, SECTOR. The location
179 ;of start of the C128 buffer to put the read data in BUFLOC.
180 ;The physical sector size in SECSIZE (1=256,2=512,4=1024).
181 ;Number of sectors in NUMSEC.
182 ;Physical side of the disk in SIDE (0 or 1).
183 ;Status byte from drive is returned in STATUS.
184
136b a9 00 185 lda #PBURSTRD ;Physical burst read command.
136d ae 1309 186 ldx SIDE ; Check which side to read from.
1370 f0 02 187 beq 1$
1372 09 10 188 ora #$10 ; If side 1, then set bit in the command byte.
1374 8d 1310 189 1$ sta cmdline+2
190
191
1377 192 READ
193
1377 ad ff00 194 lda $ff00 ;Save old MMU setup.
137a 48 195 pha
196
137b a9 0e 197 lda #$0e ;Set MMU for RAM0,KERNEL,I/O.
137d 8d ff00 198 sta $ff00
199
1380 20 167d 200 jsr SETU0 ;Put "U0" at start of command string.
201
1383 ad 1303 202 lda TRACK
1386 8d 1311 203 sta CMDLINE+3 ; track
1389 ad 1304 204 lda SECTOR
138c 8d 1312 205 sta CMDLINE+4 ; sector
138f ad 1305 206 lda NUMSEC
1392 8d 1313 207 sta CMDLINE+5 ; Number of sectors to read.
208
1395 a9 06 209 lda #$06 ; Length of command string.
1397 8d 131a 210 sta CMDLEN
139a 20 1664 211 jsr sendcmd ; send cmd string
212
139d ad 1306 213 lda BUFLOC ; Set up zero page indirect pointer.
13a0 85 fa 214 sta BUFFER
13a2 ad 1307 215 lda BUFLOC+1
13a5 85 fb 216 sta BUFFER+1
217
13a7 a0 00 218 ldy #0 ; clear the 'empty sector(s)' flag.
13a9 8c 130d 219 sty flag
220
13ac 78 221 sei ; No irq's allowed during handshake.
222
13ad 2c dc0d 223 bit d1icr ; clear pending
224
13b0 20 169c 225 jsr CLK_CHNG ;Change state of clock.
.main. hcd65xx v3.1 03-23-87 page 5
0:burst subs.src,s,r
error addr code seq source statement
226
13b3 ae 1308 227 1$ ldx SECSIZE ; Sector size gives # of pages per sector.
228
13b6 20 16a5 229 jsr WAIT ;Wait for fast byte (1st is status).
13b9 ad dc0c 230 lda d1sdr ;Get status byte.
13bc 8d 1300 231 sta STATUS
232
13bf 29 0f 233 and #15 ;Was there an error?
13c1 c9 02 234 cmp #2 ;
13c3 b0 21 235 bcs 5$ ; branch if error occured.
236
13c5 20 169c 237 jsr CLK_CHNG ;Change clock so next byte is sent.
238
13c8 20 16a5 239 3$ jsr WAIT ;Wait for the next byte.
240
13cb 20 169c 241 jsr CLK_CHNG ;Change state of clock so next byte is sent.
13ce ad dc0c 242 lda D1SDR ;Get the data byte
13d1 91 fa 243 sta (buffer),y ; and save it
244 ; while next byte is being transmitted.
245
13d3 0d 130d 246 ora flag ;Update 'zero' sector flag.
13d6 8d 130d 247 sta flag
248
13d9 c8 249 iny ;Any more in this page?
13da d0 ec 250 bne 3$
251
13dc e6 fb 252 inc BUFFER+1
13de ca 253 dex ;Loop for the # of pages per sector.
13df d0 e7 254 bne 3$
255
13e1 ce 1313 256 dec CMDLINE+5 ;Loop for the number of sectors.
13e4 d0 cd 257 bne 1$
258
13e6 58 259 5$ cli
260
13e7 68 261 pla ;Restore MMU to old configuration.
13e8 8d ff00 262 sta $ff00
263
13eb 60 264 rts
265
266 ;**************************************************************************
267
13ec 268 LWRITE ;Logical sector write to the device indicated by LF.
269 ;The track and sector are in TRACK, SECTOR. The location
270 ;of start of C128 buffer containing write data in BUFLOC.
271 ;Status byte from drive is returned in STATUS.
272
13ec a9 82 273 lda #lburstwr
13ee 8d 1310 274 sta cmdline+2 ; burst write
13f1 a9 01 275 lda #$01
13f3 8d 1308 276 sta SECSIZE ; Logical sector size is always 256 bytes.
13f6 4c 1405 277 jmp WRITE
278
279
13f9 280 PWRITE ;Physical sector write to the device indicated by LF.
281 ;The track and sector are in TRACK, SECTOR. The location
282 ;of start of C128 buffer containing write data in BUFLOC.
.main. hcd65xx v3.1 03-23-87 page 6
0:burst subs.src,s,r
error addr code seq source statement
283 ;The physical sector size in SECSIZE (1=256,2=512,4=1024).
284 ;Number of sectors in NUMSEC.
285 ;Physical side in SIDE.
286 ;Status byte from drive is returned in STATUS.
287
13f9 a9 02 288 lda #PBURSTWR ;Physical burst write command.
13fb ae 1309 289 ldx SIDE ; Check which side to write to.
13fe f0 02 290 beq 1$
1400 09 10 291 ora #$10 ; If side 1, then set bit in the command byte.
1402 8d 1310 292 1$ sta cmdline+2
293
294
1405 295 WRITE
296
1405 ad ff00 297 lda $ff00 ;Save old MMU setup.
1408 48 298 pha
299
1409 a9 0e 300 lda #$0e ;Set MMU for RAM0,KERNEL,I/O.
140b 8d ff00 301 sta $ff00
302
140e 20 167d 303 jsr SETU0 ;Put "U0" at start of command string.
1411 ad 1303 304 lda TRACK
1414 8d 1311 305 sta CMDLINE+3 ; track
1417 ad 1304 306 lda SECTOR
141a 8d 1312 307 sta CMDLINE+4 ; sector
141d ad 1305 308 lda NUMSEC
1420 8d 1313 309 sta CMDLINE+5 ; Number of sectors to write.
310
1423 a9 06 311 lda #$06
1425 8d 131a 312 sta CMDLEN ;Command length.
1428 20 1664 313 jsr sendcmd ; send cmd string
314
142b ad 1306 315 lda BUFLOC ; Set up zero page indirect pointer.
142e 85 fa 316 sta BUFFER
1430 ad 1307 317 lda BUFLOC+1
1433 85 fb 318 sta BUFFER+1
319
1435 a9 40 320 lda #clkin ;Initial clock status.
1437 8d 131b 321 sta oldclk
322
143a a0 00 323 ldy #0
143c 78 324 sei ; no irq's during burst handshake
325
143d ae 1308 326 1$ ldx SECSIZE ; Sector size gives # of pages per sector.
327
1440 38 328 sec ;Turn fast serial to output mode.
1441 20 ff47 329 jsr spin_out
330
1444 ad dd00 331 2$ lda d2pra ;Wait for state change.
1447 4d 131b 332 eor oldclk
144a 29 40 333 and #clkin
144c f0 f6 334 beq 2$
335
144e 4d 131b 336 eor oldclk ;Change status of OLDCLK.
1451 8d 131b 337 sta oldclk
338
1454 b1 fa 339 lda (buffer),y ; get data
.main. hcd65xx v3.1 03-23-87 page 7
0:burst subs.src,s,r
error addr code seq source statement
1456 8d dc0c 340 sta d1sdr ; & send it
341
1459 20 16a5 342 jsr WAIT ;Wait for the byte to be transmitted.
343
145c c8 344 iny
145d d0 e5 345 bne 2$ ;Any more left in this page?
346
145f e6 fb 347 inc buffer+1
1461 ca 348 dex ;Loop for the # of pages per sector.
1462 d0 e0 349 bne 2$
350
1464 18 351 clc ;Turn around to input mode to get STATUS.
1465 20 ff47 352 jsr spin_out
353
1468 2c dc0d 354 bit d1icr ; clear pending
355
146b 20 1688 356 jsr clklo ; set clock low when ready for status
357
146e 20 16a5 358 jsr WAIT ;Wait for the byte to be shifted in.
1471 ad dc0c 359 lda d1sdr ;Get the status byte.
1474 8d 1300 360 sta STATUS ;Save it.
1477 48 361 pha
1478 20 1693 362 jsr clkhi ;Release the slow clock line.
147b 68 363 pla
364
147c 29 0f 365 and #15 ;Check for any error.
147e c9 02 366 cmp #2
1480 b0 05 367 bcs 7$ ; branch if there was an error.
368
1482 ce 1313 369 dec CMDLINE+5 ;Loop for the number of sectors.
1485 d0 b6 370 bne 1$
371
1487 58 372 7$ cli
373
1488 68 374 pla ;Restore old memory configuration.
1489 8d ff00 375 sta $ff00
376
148c 60 377 rts
378
379 ;**********************************************************************
380
148d 381 INQUIRE_FORMAT ;Sends an INQUIRE DISK command to the drive indicate by
382 ;the logical file (LF). Status is returned in STATUS.
383
148d 20 167d 384 jsr SETU0 ;Put "U0" at start of command string.
1490 a9 04 385 lda #BURST_INQUIRE ; inquire burst command
1492 8d 1310 386 sta cmdline+2
1495 a9 03 387 lda #$03 ; length of command.
1497 8d 131a 388 sta CMDLEN
149a 20 1664 389 jsr sendcmd ; send cmd string
390
149d 78 391 sei ;Disable interrupts during handshake.
392
149e 2c dc0d 393 bit D1ICR ;Clear any byte ready that's pending.
394
14a1 20 169c 395 jsr CLK_CHNG ;Change clock so 1581 sends next.
14a4 20 16a5 396 jsr WAIT ;Wait for the byte to be shifted in.
.main. hcd65xx v3.1 03-23-87 page 8
0:burst subs.src,s,r
error addr code seq source statement
14a7 ad dc0c 397 lda D1SDR ;Get the status byte.
14aa 8d 1300 398 sta STATUS ;Save it off.
399
14ad 58 400 cli
14ae 60 401 rts
402
403 ;**********************************************************************
404
14af 405 QUERY_FORMAT ;Sends a QUERY DISK FORMAT command to the drive indicate by
406 ;the logical file (LF). Physical track number to query
407 ;should be provided in TRACK. Physical side should
408 ;be provided in SIDE. Status is returned in STATUS.
409 ;Number of sectors found on the track returned in NUMSEC.
410 ;Logical track number found in the sector headers returned
411 ;in TRACK. Minimum logical sector number found in the
412 ;sector headers is returned in MINSEC. The maximium
413 ;logical sector is returned MAXSEC. Physical interleave
414 ;is returned in INTLV.
415 ;If an error is encountered in compiling this information
416 ;(as indicated by STATUS), then none of the return values
417 ;are valid (except STATUS).
418
14af 20 167d 419 jsr SETU0 ;Put "U0" at start of command string.
420
14b2 a9 86 421 lda #BURST_QUERY ;QUERY DISK burst command
14b4 ae 1309 422 ldx SIDE ; Set the side bit accordingly.
14b7 d0 02 423 bne 4$
14b9 09 10 424 ora #$10
14bb 8d 1310 425 4$ sta cmdline+2
426
14be ad 1303 427 lda TRACK ; Physical track offset.
14c1 8d 1311 428 sta cmdline+3
14c4 a9 04 429 lda #$04 ; length of command.
14c6 8d 131a 430 sta CMDLEN
14c9 20 1664 431 jsr sendcmd ; send cmd string
432
14cc 78 433 sei ;Disable interrupts during handshake.
434
14cd 2c dc0d 435 bit D1ICR ;Clear any byte ready that's pending.
436
14d0 20 169c 437 jsr CLK_CHNG ;Change state of clock so 1581 sends next.
14d3 20 16a5 438 jsr WAIT ;Wait for the first status byte.
14d6 ad dc0c 439 lda D1SDR ;Get the status byte (status of track 0).
14d9 8d 1300 440 sta STATUS ;Save it off.
441
14dc 29 0f 442 and #$0f ;Was there an error?
14de c9 02 443 cmp #2
14e0 b0 4e 444 bcs 5$ ; branch if there was an error.
445
14e2 20 169c 446 jsr CLK_CHNG ;Change state of clock, so 1581 sends next.
14e5 20 16a5 447 jsr WAIT ;Wait for next status byte to be ready.
14e8 ad dc0c 448 lda D1SDR ;Get it (status of track TRACK).
14eb 8d 1300 449 sta STATUS ;Save it.
450
14ee 29 0f 451 and #$0f ;Was there an error?
14f0 c9 02 452 cmp #2
14f2 b0 3c 453 bcs 5$ ; branch if an error.
.main. hcd65xx v3.1 03-23-87 page 9
0:burst subs.src,s,r
error addr code seq source statement
454
14f4 20 169c 455 jsr CLK_CHNG ;Change state of clock, so 1581 sends next.
14f7 20 16a5 456 jsr WAIT ;Wait for 'number of sectors byte' to be ready.
14fa ad dc0c 457 lda D1SDR ;Get it.
14fd 8d 1305 458 sta NUMSEC ;Save it.
459
460
1500 20 169c 461 jsr CLK_CHNG ;Change state of clock, so 1581 sends next.
1503 20 16a5 462 jsr WAIT ;Wait for 'logical track #' byte to be ready.
1506 ad dc0c 463 lda D1SDR ;Get it.
1509 8d 1303 464 sta TRACK ;Save it.
465
150c 20 169c 466 jsr CLK_CHNG ;Change state of clock, so 1581 sends next.
150f 20 16a5 467 jsr WAIT ;Wait for 'minimum sector #' byte to be ready.
1512 ad dc0c 468 lda D1SDR ;Get it.
1515 8d 130a 469 sta MINSEC ;Save it.
470
1518 20 169c 471 jsr CLK_CHNG ;Change state of clock, so 1581 sends next.
151b 20 16a5 472 jsr WAIT ;Wait for 'maximum sector #' byte to be ready.
151e ad dc0c 473 lda D1SDR ;Get it.
1521 8d 130b 474 sta MAXSEC ;Save it.
475
1524 20 169c 476 jsr CLK_CHNG ;Change state of clock, so 1581 sends next.
1527 20 16a5 477 jsr WAIT ;Wait for 'interleave' byte to be ready.
152a ad dc0c 478 lda D1SDR ;Get it.
152d 8d 130c 479 sta INTLV ;Save it.
480
1530 58 481 5$ cli
1531 60 482 rts
483
484 ;***************************************************************************
485
1532 486 MEMORY_READ ;Burst memory read of the 1581. Page in 1581 memory to
487 ;start reading at in .X, number of pages to read in .Y,
488 ;location to store data in C128 memory in BUFLOC.
489 ;Logical file to be read from in LF.
490
1532 ad ff00 491 lda $ff00 ;Save old MMU setup.
1535 48 492 pha
493
1536 a9 0e 494 lda #$0e ;Set MMU for RAM0,KERNEL,I/O.
1538 8d ff00 495 sta $ff00
496
153b 20 167d 497 jsr SETU0 ;Put "U0" at start of command string.
153e a9 3e 498 lda #$3E ;('>') 'burst memory read' command string.
1540 8d 1310 499 sta CMDLINE+2 ; ( "U0>MR" )
1543 a9 4d 500 lda #$4D ;('M')
1545 8d 1311 501 sta CMDLINE+3
1548 a9 52 502 lda #$52 ;('R')
154a 8d 1312 503 sta CMDLINE+4
154d 8e 1313 504 stx CMDLINE+5 ; 1581 page to start reading from.
1550 8c 1314 505 sty CMDLINE+6 ; # of pages to read.
506
1553 a9 07 507 lda #$07 ; Length of command string.
1555 8d 131a 508 sta CMDLEN
1558 20 1664 509 jsr sendcmd ; send cmd string
510
.main. hcd65xx v3.1 03-23-87 page 10
0:burst subs.src,s,r
error addr code seq source statement
155b ad 1306 511 lda BUFLOC ; Set up zero page indirect pointer.
155e 85 fa 512 sta BUFFER
1560 ad 1307 513 lda BUFLOC+1
1563 85 fb 514 sta BUFFER+1
515
1565 a9 00 516 lda #0 ; clear the 'empty sector(s)' flag.
1567 8d 130d 517 sta flag
518
156a 78 519 sei ; No irq's allowed during handshake.
520
156b 2c dc0d 521 bit d1icr ; clear pending
522
156e 20 169c 523 jsr CLK_CHNG ;Change state of clock.
524
1571 a0 00 525 ldy #0
1573 20 16a5 526 3$ jsr WAIT ;Wait for the byte to be shifted in.
527
1576 20 169c 528 jsr CLK_CHNG ;Change clock so next byte is sent.
1579 ad dc0c 529 lda d1sdr ; get data
157c 91 fa 530 sta (buffer),y ; and save it while next byte is transmitted.
531
157e 0d 130d 532 ora flag ; Update 'zero' flag.
1581 8d 130d 533 sta flag
534
1584 c8 535 iny
1585 d0 ec 536 bne 3$ ;Any more in this page?
537
1587 e6 fb 538 inc BUFFER+1
1589 ce 1314 539 dec CMDLINE+6 ;Any more pages to do?
158c d0 e5 540 bne 3$
541
158e 58 542 5$ cli
543
158f 68 544 pla ;Restore old memory configuration.
1590 8d ff00 545 sta $ff00
546
1593 60 547 rts
548
549
550 ;***************************************************************************
551
1594 552 MEMORY_WRITE ;Burst memory write to the 1581's memory. The
553 ;location in C128 memory to send data from in BUFLOC.
554 ;The page in 1581 memory to start writing to in .X.
555 ;The number of pages to write in .Y.
556 ;Logical file to be written to in LF.
557
1594 ad ff00 558 lda $ff00 ;Save old MMU setup.
1597 48 559 pha
560
1598 a9 0e 561 lda #$0e ;Set MMU for RAM0,KERNEL,I/O.
159a 8d ff00 562 sta $ff00
563
159d 20 167d 564 jsr SETU0 ;Put "U0" at start of command string.
15a0 a9 3e 565 lda #$3E ;('>') 'burst memory write' command string.
15a2 8d 1310 566 sta CMDLINE+2 ; ( "U0>MW" )
15a5 a9 4d 567 lda #$4D ;('M')
.main. hcd65xx v3.1 03-23-87 page 11
0:burst subs.src,s,r
error addr code seq source statement
15a7 8d 1311 568 sta CMDLINE+3
15aa a9 57 569 lda #$57 ;('W')
15ac 8d 1312 570 sta CMDLINE+4
15af 8e 1313 571 stx CMDLINE+5 ; 1581 page to start writing to.
15b2 8c 1314 572 sty CMDLINE+6 ; # of pages to write.
573
15b5 a9 07 574 lda #$07 ; Length of command string.
15b7 8d 131a 575 sta CMDLEN
576
15ba 20 1664 577 jsr sendcmd ; send cmd string
578
15bd ad 1306 579 lda BUFLOC ; Set up zero page indirect pointer.
15c0 85 fa 580 sta BUFFER
15c2 ad 1307 581 lda BUFLOC+1
15c5 85 fb 582 sta BUFFER+1
583
15c7 a9 40 584 lda #clkin ;Initial clock status.
15c9 8d 131b 585 sta oldclk
586
15cc a0 00 587 ldy #0
15ce 78 588 sei ;No IRQ's allowed during handshake.
589
15cf 38 590 sec ; Set to output mode.
15d0 20 ff47 591 jsr SPIN_OUT
592
15d3 ad dd00 593 2$ lda d2pra ;Wait for state (slow clock line) change.
15d6 4d 131b 594 eor OLDCLK
15d9 29 40 595 and #CLKIN
15db f0 f6 596 beq 2$
597
15dd 4d 131b 598 eor OLDCLK ;Change status of OLDCLK variable.
15e0 8d 131b 599 sta OLDCLK
600
15e3 b1 fa 601 lda (BUFFER),y ;Get data to write.
15e5 8d dc0c 602 sta D1SDR ;Send it.
603
15e8 20 16a5 604 jsr WAIT ;Wait for the byte to be sent.
605
15eb c8 606 iny
15ec d0 e5 607 bne 2$ ;More in this page?
608
15ee e6 fb 609 inc BUFFER+1
15f0 ce 1314 610 dec CMDLINE+6
15f3 d0 de 611 bne 2$ ;Any more pages to send?
612
15f5 58 613 cli
614
15f6 68 615 pla ;Restore old memory configuration.
15f7 8d ff00 616 sta $ff00
617
15fa 60 618 rts
619
620 ;***************************************************************************
621
15fb 622 DUMP_CACHE ;Dumps the track cache at 1581 $0C00 to the physical track
623 ;specified in TRACK, on the side specified in SIDE. The
624 ;'force' bit is set, so it is written whether it is dirty
.main. hcd65xx v3.1 03-23-87 page 12
0:burst subs.src,s,r
error addr code seq source statement
625 ;or not.
626
15fb 20 167d 627 jsr SETU0
15fe a9 9c 628 lda #DUMPCACHE ;Dump track cache command.
629
1600 ae 1309 630 ldx SIDE ; Set SIDE bit accordingly.
1603 f0 02 631 beq 1$
1605 09 40 632 ora #$40
633
1607 8d 1310 634 1$ sta CMDLINE+2 ; Put the command byte into command string.
160a ad 1303 635 lda TRACK
160d 8d 1311 636 sta CMDLINE+3 ; Physical track to dump cache to.
637
1610 a9 04 638 lda #4
1612 8d 131a 639 sta CMDLEN ;Length of the command string.
1615 20 1664 640 jsr SENDCMD
641
1618 78 642 sei ;Disable interrupts during handshake.
643
1619 2c dc0d 644 bit D1ICR ;Clear any byte ready that's pending.
645
161c 20 169c 646 jsr CLK_CHNG ;Change clock so 1581 will send status byte.
161f 20 16a5 647 jsr WAIT ;Wait for byte to be shifted in.
1622 ad dc0c 648 lda D1SDR ;Get the status byte.
1625 8d 1300 649 sta STATUS ;Save it off.
650
1628 58 651 cli
1629 60 652 rts
653
654 ;***************************************************************************
655
162a 656 COMPARE_MEMORY ;Compares memory blocks in the C128 memory.
657 ;Number of pages to compare in .A.
658 ;First page of first memory block in .X.
659 ;First page of second memory block in .Y.
660 ;If they are equal, then STATUS=0.
661
162a 8d 131c 662 sta temp
663
162d ad ff00 664 lda $ff00 ;Save old MMU setup.
1630 48 665 pha
666
1631 a9 0e 667 lda #$0e ;Set MMU for RAM0,KERNEL,I/O.
1633 8d ff00 668 sta $ff00
669
1636 86 fb 670 stx buffer+1 ;Set up MSB of 1st memory pointer.
1638 84 fd 671 sty buffer2+1 ;Set up MSB of 2nd memory pointer.
163a ae 131c 672 ldx temp ;Number of pages to compare.
673
163d a9 00 674 lda #0 ;Set up LSB's of memory pointers.
163f 85 fa 675 sta buffer
1641 85 fc 676 sta buffer2
677
1643 8d 1300 678 sta STATUS ;Initialize STATUS.
679
1646 a0 00 680 ldy #0
681
.main. hcd65xx v3.1 03-23-87 page 13
0:burst subs.src,s,r
error addr code seq source statement
1648 b1 fa 682 2$ lda (buffer),y
164a d1 fc 683 cmp (buffer2),y
164c f0 07 684 beq 1$
685
164e a9 ff 686 lda #$ff ;Not equal! Load STATUS with nonzero.
1650 8d 1300 687 sta STATUS
1653 d0 0a 688 bne 99$ ; (branch always)
689
1655 c8 690 1$ iny
1656 d0 f0 691 bne 2$ ;More in this page?
692
1658 e6 fb 693 inc buffer+1
165a e6 fd 694 inc buffer2+1
165c ca 695 dex ;# of pages counter.
165d d0 e9 696 bne 2$
697
165f 68 698 99$ pla ;Restore old memory configuration.
1660 8d ff00 699 sta $ff00
700
1663 60 701 rts
702
703 ;***************************************************************************
704
1664 705 SENDCMD ;Sends the command in CMDLINE to the logical file
706 ;indicated by LF. Length of the command should be in CMDLEN.
707
1664 ae 1302 708 ldx LF
1667 20 ffc9 709 jsr chkout ; channel output (pointed to by .X)
166a a2 00 710 ldx #0
166c ac 131a 711 ldy cmdlen ; send cmd
166f bd 130e 712 1$ lda cmdline,x
1672 20 ffd2 713 jsr bsout
1675 e8 714 inx
1676 88 715 dey
1677 d0 f6 716 bne 1$
717
1679 20 ffcc 718 jsr clrchn ; send buffered char & eoi
167c 60 719 rts
720
721 ;***************************************************************************
722
167d a9 55 723 SETU0 lda #85 ;'U'
167f 8d 130e 724 sta CMDLINE
1682 a9 30 725 lda #48 ;'0'
1684 8d 130f 726 sta CMDLINE+1
1687 60 727 rts
728
729
1688 730 CLKLO ; set clock low
1688 48 731 pha
1689 ad dd00 732 lda d2pra
168c 09 10 733 ora #clkout
168e 8d dd00 734 sta d2pra
1691 68 735 pla
1692 60 736 rts
737
1693 738 CLKHI ; set clock high
.main. hcd65xx v3.1 03-23-87 page 14
0:burst subs.src,s,r
error addr code seq source statement
1693 ad dd00 739 lda d2pra
1696 29 ef 740 and #$ff-clkout
1698 8d dd00 741 sta d2pra
169b 60 742 rts
743
169c 744 CLK_CHNG ; change the state of the clock line output.
169c ad dd00 745 lda D2PRA
169f 49 10 746 eor #clkout
16a1 8d dd00 747 sta D2PRA
16a4 60 748 rts
749
16a5 750 WAIT ; wait for the shift register to be full or empty.
16a5 a9 08 751 1$ lda #8
16a7 2c dc0d 752 bit D1ICR
16aa f0 f9 753 beq 1$
16ac 60 754 rts
755
756
757 .end
0 errors detected
.main. hcd65xx v3.1 03-23-87 page 15
symbol table
<blank> = label, <=> = symbol, <+>= multibly defined
bsout =ffd2 buffer =00fa buffer2 =00fc bufloc 1306 burst_inquire =0004
burst_query =0086 chkout =ffc9 clkhi 1693 clkin =0040 clklo 1688
clkout =0010 clk_chng 169c clrchn =ffcc cmdlen 131a cmdline 130e
compare_memory 162a d1icr =dc0d d1sdr =dc0c d2pra =dd00 dev 1301
dumpcache =009c dump_cache 15fb flag 130d inquire_format 148d intlv 130c
j_compare_memory 135b j_dump_cache 1355 j_inquire_format 1340 j_logical_read 1346 j_logical_write 134c
j_memory_read 134f j_memory_write 1352 j_physical_read 1343 j_physical_write 1349 j_query_format 1358
lburstrd =0080 lburstwr =0082 lf 1302 lread 135e lwrite 13ec
maxsec 130b memory_read 1532 memory_write 1594 minsec 130a numsec 1305
oldclk 131b pburstrd =0000 pburstwr =0002 pread 136b pwrite 13f9
query_format 14af read 1377 secsize 1308 sector 1304 sendcmd 1664
setlfs =ffba setnam =ffbd setu0 167d side 1309 spin_out =ff47
status 1300 temp 131c track 1303 wait 16a5 write 1405